<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<!-- <el-form-item>
					<el-input v-model="filters.name" placeholder="设备IP"></el-input>
				</el-form-item> -->
				<el-form-item>
					<el-button type="primary" @click="screenEdit">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-show="my_permi.indexOf('flowExtemal.export') > -1 || my_permi.indexOf('admin') > -1" @click="exportT">导出</el-button>
				</el-form-item>
				<el-form-item v-show="my_permi.indexOf('settlementWeight.shipang') > -1 || my_permi.indexOf('admin') > -1">
					<el-button type="primary" @click="shiBang" v-show="is_shibang == '0'">开始试磅</el-button>
					<el-button type="primary" @click="shiBang" v-show="is_shibang == '1'">结束试磅</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="cardList" highlight-current-row v-loading="listLoading" style="width: 100%;" :height="clientHeight">
			<!-- <el-table-column type="index" width="60">
			</el-table-column> -->
			<el-table-column prop="system_datetime" label="制卡时间" width="140">
			</el-table-column>
			<el-table-column prop="ic_id" label="IC卡卡号" width="140">
			</el-table-column>
			<el-table-column prop="ic_print_code" label="印刷编号" width="140">
			</el-table-column>
			<el-table-column prop="weightdata.process_number_desc" label="流程类型" width="140">
			</el-table-column>
			<el-table-column prop="sfz_number" label="司机身份证号码" width="140">
			</el-table-column>
			<el-table-column prop="weightdata.vehicle_number" fixed label="车牌号" width="140">
			</el-table-column>
			<el-table-column label="初称信息" width="110">
				<template slot-scope="scope" v-if="scope.row.weightdata">
					<el-button size="small" type="primary" @click="viewDetails1(scope.$index)">查看</el-button>
				</template>
			</el-table-column>
			<el-table-column label="采购重量" width="150">
				<template slot-scope="scope">
					<span
						v-if="scope.row.flow_extemal&&scope.row.weightdata"
						style=""
					>
						{{(scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') ? scope.row.flow_extemal.purchase_weight : '0'}}
					</span>
					<el-button
						v-if="scope.row.flow_extemal&&scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.purchase_weight.put') > -1 || my_permi.indexOf('admin') > -1) && (scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'purchase_weight')"
					>修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="卸货重量" width="150">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal&&scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') ? scope.row.flow_extemal.discharge_weight : '0'}}</span>
					<el-button
						v-if="scope.row.flow_extemal&&scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.discharge_weight.put') > -1 || my_permi.indexOf('admin') > -1) && (scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'discharge_weight')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="误差重量" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal&&scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') ? scope.row.flow_extemal.relative_weight : '0'}}</span>
				</template>
			</el-table-column>
			<el-table-column label="提货重量" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALE') ? scope.row.flow_extemal.pick_weight : 0}}</span>
					<el-button
						v-if="scope.row.flow_extemal&&scope.row.weightdata"
						size="small"
						v-show="(my_permi.indexOf('flowExtemal.pick_weight.put') > -1 || my_permi.indexOf('admin') > -1) && scope.row.weightdata.process_number == 'SALE' && scope.row.weightdata.is_finished !== 'Y'"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'pick_weight')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="出门重量" width="110">
				<template slot-scope="scope">
					<span v-if="scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALE') ? scope.row.flow_extemal.out_weight : 0}}</span>
					<el-button
						v-if="scope.row.flow_extemal&&scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.out_weight.put') > -1 || my_permi.indexOf('admin') > -1) && scope.row.weightdata.process_number == 'SALE' && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'out_weight')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="地磅净重（卸）" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal&&scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') ? scope.row.flow_extemal.net_weight : '0'}}</span><!-- {{scope.row.weightdata.net_weight}} -->
				</template>
			</el-table-column>
			<el-table-column label="地磅净重（装）" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALE') ? scope.row.weightdata.net_weight : 0}}</span>
					<!-- {{scope.row.weightdata.net_weight}} -->
				</template>
			</el-table-column>
			<el-table-column label="回称信息" width="110">
				<template slot-scope="scope" v-if="scope.row.weightdata">
					<el-button size="small" type="primary" @click="viewDetails2(scope.$index)">查看</el-button>
				</template>
			</el-table-column>
			<el-table-column prop="weightdata.is_finished_desc" label="是否过磅" width="110">
			</el-table-column>
			<el-table-column label="误差重量（卸）" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal&&scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALEBACK' || scope.row.weightdata.process_number == 'PURCHASE') ? scope.row.weightdata.weight_error : '0'}}</span>
				</template>
			</el-table-column>
			<el-table-column label="误差重量（装）" width="140">
				<template slot-scope="scope">
					<span v-if="scope.row.weightdata" style="">{{(scope.row.weightdata.process_number == 'SALE') ? scope.row.weightdata.weight_error : 0}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="weightdata.weight_error_ratio" label="误差比值" width="110">
			</el-table-column>
			<el-table-column prop="weightdata.is_finished_desc" label="是否成功" width="110">
			</el-table-column>
			<el-table-column prop="weightdata.is_success_desc" label="是否完成" width="110">
			</el-table-column>
			<el-table-column prop="weightdata.second_readic_datetime" label="完成时间" width="110">
			</el-table-column>
			<el-table-column label="是否退货" width="110">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal" style="">{{scope.row.flow_extemal.is_return_desc}}</span>
					<el-button
						v-if="scope.row.flow_extemal && scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.is_return.put') > -1 || my_permi.indexOf('admin') > -1) && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'is_return')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="是否可以出门" width="160">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal" style="">{{scope.row.flow_extemal.is_go_desc}}</span>
					<el-button
						v-if="scope.row.flow_extemal && scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.is_go.put') > -1 || my_permi.indexOf('admin') > -1) && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'is_go')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="异常备案" width="120">
				<template slot-scope="scope">
					<span v-if="scope.row.flow_extemal" style="">{{scope.row.flow_extemal.remarks}}</span>
					<el-button
						v-if="scope.row.flow_extemal && scope.row.weightdata"
						v-show="(my_permi.indexOf('flowExtemal.remark.put') > -1 || my_permi.indexOf('admin') > -1) && scope.row.weightdata.is_finished !== 'Y'"
						size="small"
						type="warning"
						@click="handleEdit(scope.$index, scope.row, 'remarks')">修改</el-button>
				</template>
			</el-table-column>
			<el-table-column label="操作" width="100">
				<template slot-scope="scope">
					<el-button size="small" type="primary" @click="showPrint(scope.$index, scope.row)">打印</el-button>
				</template>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination
				layout="prev, pager, next"
				@current-change="handleCurrentChange"
				:total="total"
				style="float:right;">
			</el-pagination>
		</el-col>

		<!-- 图片放大 -->
		<el-dialog title="展示图片" v-model="is_zoom_img" class="zoom-img-dialog" :close-on-click-modal="false">
			<img class="zoom_img_id" :src="zoom_img">
		</el-dialog>

		<!--查看初称、回称界面-->
		<el-dialog title="初次称重信息" v-model="detailsVisible" :close-on-click-modal="false">
			<div class="weightD"><span>初称刷卡时间：</span> <span>{{details.first_readic_datetime}}</span></div>
			<div class="weightD"><span>初称重量：</span> <span>{{details.first_weight}}</span></div>
			<!-- <div class="weightD"><span>初称地磅编号：</span> <span>{{details.first_wbid}}</span></div> -->
			<div class="weightD"><span>初称车辆抓拍图片：</span> <img :src="details.first_capvh_path +'/'+ details.first_capvh_filename" @click="isZoom(details.first_capvh_path +'/'+ details.first_capvh_filename)"><span class="print-btn" @click="printBtn(details.first_capvh_path +'/'+ details.first_capvh_filename)">打印</span></div>
			<div class="weightD"><span>初称地磅抓拍A：</span> <img :src="details.first_cap_a_path +'/'+ details.first_cap_a_fielname" @click="isZoom(details.first_cap_a_path +'/'+details.first_cap_a_fielname)"><span class="print-btn" @click="printBtn(details.first_capvh_path +'/'+ details.first_capvh_filename)">打印</span></div>
			<div class="weightD"><span>初称地磅抓拍B：</span> <img :src="details.first_cap_b_path +'/'+ details.first_cap_b_fielname" @click="isZoom(details.first_cap_b_path +'/'+details.first_cap_b_fielname)"><span class="print-btn" @click="printBtn(details.first_capvh_path +'/'+ details.first_capvh_filename)">打印</span></div>
		</el-dialog>

		<!--查看初称、回称界面-->
		<el-dialog title="回次称重信息" v-model="detailsVisible2" :close-on-click-modal="false">
			<div class="weightD"><span>回称刷卡时间：</span> <span>{{details.second_readic_datetime}}</span></div>
			<div class="weightD"><span>回称重量：</span> <span>{{details.second_weight}}</span></div>
			<!-- <div class="weightD"><span>回称地磅编号：</span> <span>{{details.second_wbid}}</span></div> -->
			<div class="weightD"><span>回称车辆抓拍图片：</span> <img :src="details.second_capvh_path +'/'+ details.second_capvh_filename" @click="isZoom(details.second_capvh_path +'/'+details.second_capvh_filename)"></div>
			<div class="weightD"><span>回称地磅抓拍A：</span> <img :src="details.second_cap_a_path +'/'+ details.second_cap_a_fielname" @click="isZoom(details.second_cap_a_path +'/'+details.second_cap_a_fielname)"></div>
			<div class="weightD"><span>回称地磅抓拍A：</span> <img :src="details.second_cap_b_path +'/'+ details.second_cap_b_fielname" @click="isZoom(details.second_cap_b_path +'/'+details.second_cap_b_fielname)"></div>
		</el-dialog>

		<!--编辑界面-->
		<el-dialog :title="title" v-model="editFormVisible" :close-on-click-modal="false">
			<el-form :model="editForm" label-width="120px" ref="editForm">
				<!-- <el-form-item label="处理情况">
					<el-select v-model="editForm.handling_situation" placeholder="请选择">
					    <el-option
					      v-for="item in options"
					      :key="item.value"
					      :label="item.label"
					      :value="item.value">
					    </el-option>
					</el-select>
				</el-form-item> -->
				<el-form-item :label="title" v-if="editType == 'purchase_weight'">
					<el-input v-model="editForm.purchase_weight" auto-complete="off"></el-input>
				</el-form-item>
				<!-- 修改卸货重量 PUT -->
				<el-form-item :label="title" v-if="editType == 'discharge_weight'">
					<el-input v-model="editForm.discharge_weight" auto-complete="off"></el-input>
				</el-form-item>
				<!-- 修改提货重量 PUT -->
				<el-form-item :label="title" v-if="editType == 'pick_weight'">
					<el-input v-model="editForm.pick_weight" auto-complete="off"></el-input>
				</el-form-item>
				<!-- 修改出门重量 PUT -->
				<el-form-item :label="title" v-if="editType == 'out_weight'">
					<el-input v-model="editForm.out_weight" auto-complete="off"></el-input>
				</el-form-item>
				<!-- 修改异常备案 -->
				<el-form-item :label="title" v-if="editType == 'remarks'">
					<el-input v-model="editForm.remarks" auto-complete="off"></el-input>
				</el-form-item>
				<!-- 修改是否退货 -->
				<el-form-item :label="title" v-if="editType == 'is_return'">
					<el-select v-model="editForm.is_return" placeholder="请选择">
					    <el-option
					      v-for="item in is_return_arr"
					      :key="item.value"
					      :label="item.label"
					      :value="item.value">
					    </el-option>
					</el-select>
				</el-form-item>
				<!-- 修改是否可以出门 -->
				<el-form-item :label="title" v-if="editType == 'is_go'">
					<el-select v-model="editForm.is_go" placeholder="请选择">
					    <el-option
					      v-for="item in is_go_arr"
					      :key="item.value"
					      :label="item.label"
					      :value="item.value">
					    </el-option>
					</el-select>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="editFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
			</div>
		</el-dialog>

        <!-- 筛选界面 -->
        <el-dialog title="筛选" v-model="screenFormVisible" :close-on-click-modal="false">
            <el-form :model="screenForm" label-width="110px" ref="screenForm">
            	<el-form-item label="过磅完成时间">
	                <el-date-picker
	                  v-model="screenForm.currentdate"
	                  type="daterange"
	                  range-separator="至"
	                  placeholder="过磅完成时间">
	                </el-date-picker>
	            </el-form-item>
                <el-form-item label="是否成功">
                	<span class="change-val" @click="changeval('is_finished', 'Y')">
                		<span class="change-val-span" v-if="screenForm.is_finished == 'N' || screenForm.is_finished == ''"></span>
                		<span class="change-val-span change-active" v-else></span>
                		是
                	</span>
                	<span class="change-val" @click="changeval('is_finished', 'N')">
                		<span class="change-val-span" v-if="screenForm.is_finished == 'Y' || screenForm.is_finished == ''"></span>
                		<span class="change-val-span change-active" v-else></span>
	                	否
	                </span>
                </el-form-item>
                <el-form-item label="是否完成">
                	<span class="change-val" @click="changeval('is_success', 'Y')">
                		<span class="change-val-span" v-if="screenForm.is_success == 'N' || screenForm.is_success == ''"></span>
                		<span class="change-val-span change-active" v-else></span>
                		出厂过磅成功
                	</span>
                	<span class="change-val" @click="changeval('is_success', 'N')">
                		<span class="change-val-span" v-if="screenForm.is_success == 'Y' || screenForm.is_success == ''"></span>
                		<span class="change-val-span change-active" v-else></span>
	                	出厂过磅失败
	                </span>
                </el-form-item>
                <el-form-item label="流程类型">
            		<el-radio v-model="screenForm.process_number" label="SALE">销售提货</el-radio>
  					<el-radio v-model="screenForm.process_number" label="SALEBACK">销售退货</el-radio>
  					<el-radio v-model="screenForm.process_number" label="PURCHASE">采购收货</el-radio>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="screenFormVisible = false">取消</el-button>
                <el-button type="primary" @click.native="screenSubmit" :loading="screenLoading">提交</el-button>
            </div>
        </el-dialog>

		<!--打印界面-->
		<el-dialog title="打印" v-model="printFormVisible" :close-on-click-modal="false">
			<el-form :model="printForm" label-width="110px" ref="printForm">
				<el-checkbox-group v-model="checkList">
					<el-checkbox :label="printForm.vehicle_number"></el-checkbox>
					<el-checkbox :label="printForm.system_datetime"></el-checkbox>
					<el-checkbox :label="printForm.ic_id"></el-checkbox>
					<el-checkbox :label="printForm.ic_print_code"></el-checkbox>
					<el-checkbox :label="printForm.process_number_desc"></el-checkbox>
					<el-checkbox :label="printForm.sfz_number"></el-checkbox>
					<!-- <el-checkbox :label="printForm.vehicle_number"></el-checkbox> -->
					<el-checkbox :label="printForm.purchase_weight"></el-checkbox>
					<el-checkbox :label="printForm.discharge_weight"></el-checkbox>
					<el-checkbox :label="printForm.relative_weight"></el-checkbox>
					<el-checkbox :label="printForm.pick_weight"></el-checkbox>
					<el-checkbox :label="printForm.out_weight"></el-checkbox>
					<el-checkbox :label="printForm.net_weight"></el-checkbox>
					<el-checkbox :label="printForm.net_weight2"></el-checkbox>
					<!-- <el-checkbox :label="printForm.vehicle_number"></el-checkbox> -->
					<el-checkbox :label="printForm.is_guobang"></el-checkbox>
					<el-checkbox :label="printForm.xie"></el-checkbox>
					<el-checkbox :label="printForm.zhuang"></el-checkbox>
					<el-checkbox :label="printForm.weight_error_ratio"></el-checkbox>
					<el-checkbox :label="printForm.is_finished"></el-checkbox>
					<el-checkbox :label="printForm.is_success"></el-checkbox>
					<el-checkbox :label="printForm.second_readic_datetime"></el-checkbox>
					<el-checkbox :label="printForm.is_return"></el-checkbox>
					<el-checkbox :label="printForm.is_go"></el-checkbox>
					<el-checkbox :label="printForm.remarks"></el-checkbox>
				</el-checkbox-group>
			</el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="printFormVisible = false">取消</el-button>
                <el-button type="primary" @click.native="printSubmit" :loading="printLoading">提交</el-button>
            </div>
		</el-dialog>
	</section>
</template>

<style>
.print-btn{
	margin-left: 15px;
	font-size: 16px;
    cursor: pointer;
}
.change-val{
	margin-right: 15px;
	cursor: pointer;
}
.change-val-span{
	border: 1px solid #bfcbd9;
	border-radius: 100px;
	width: 18px;
	height: 18px;
	display: inline-block;
	vertical-align: middle;
	box-sizing: border-box;
	position: relative;
	top: -1px;
}
.change-val-span.change-active:after{
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #fff;
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    -ms-transform: translate(-50%,-50%) scale(0);
    transform: translate(-50%,-50%) scale(0);
    transition: transform .15s cubic-bezier(.71,-.46,.88,.6);
    transform: translate(-50%,-50%) scale(1);
}
.change-val-span.change-active{
    border-color: #20a0ff;
    background: #20a0ff;
}
</style>

<script>
	import { flowExtemal, flowExtemalEdit, isReturn, isGo, BASEURL, isShibang, systemConfig } from '@/api/api';
    import { mapState } from 'vuex'
	export default {
		data() {
			return {
				filters: {
					name: ''
				},
				cardList: [],
				total: 0,
				page: 1,
				listLoading: false,
				is_zoom_img: false,
				zoom_img: '',
				detailsVisible: false,
				details: {},
				detailsVisible2: false,
				// 编辑采购重量
				editFormVisible: false,
				editForm: {
					// purchase_weight: '',
				},
				title: '',
				editLoading: false,
				editText: '',
				editType: '',
				is_return_arr: [],
				is_go_arr: [],
                screenFormVisible: false,//新增界面是否显示
                screenLoading: false,
                //新增界面数据
                screenForm: {
                    is_finished: '',
                    is_success: '',
                    currentdate: [],
                    process_number: '',
                },
                finishArr: [
                	{
						label: '是',
						value: 'Y',
					},
                	{
						label: '否',
						value: 'N',
					}
                ],
                successArr: [
                	{
						label: '出厂过磅成功',
						value: 'Y',
					},
                	{
						label: '出厂过磅失败',
						value: 'N',
					},
                ],
                processArr: [
                	{
						label: '销售提货',
						value: 'SALE',
					},
                	{
						label: '销售退货',
						value: 'SALEBACK',
					},
                	{
						label: '采购收货',
						value: 'PURCHASE',
					},
                ],
				is_shibang: '',
				printForm: {},
				checkList: [],
				printFormVisible: false,
				printLoading: false,
			}
		},
        computed: {
            ...mapState(
                {
                  'my_permi': state => state.my_permi,
                  'clientHeight': state => state.clientHeight
                }
            )
        },
		methods: {
			router(path) {
				this.$router.push(path)
			},
			handleCurrentChange(val) {
				this.page = val;
				this.flowExtemal(this.screenForm);
			},
			changeval(type, val) {
				if(type == 'is_finished'){
					this.screenForm.is_finished = (this.screenForm.is_finished == val) ? "" : val;
				}else if(type == 'is_success'){
					this.screenForm.is_success = (this.screenForm.is_success == val) ? "" : val;
				}
			},
			//获取设备警报信息
			flowExtemal(para) {
                let paras = `page=${this.page}`;
                if(para){
                    if(para.currentdate.length>0){
						let begin = new Date(para.currentdate[0]);
						let end = new Date(para.currentdate[1]);
						paras += `&start_time=${begin.getFullYear() + '-' + (begin.getMonth()+1) + '-' + begin.getDate()}`;
						paras += `&end_time=${end.getFullYear() + '-' + (end.getMonth()+1) + '-' + end.getDate()}`;
                    }
                    if(para.is_finished){
                      paras += `&is_finished=${para.is_finished}`
                    }
                    if(para.is_success){
                      paras += `&is_success=${para.is_success}`
                    }
                    if(para.process_number){
                      paras += `&process_number=${para.process_number}`
                    }
                }
				this.listLoading = true;
				flowExtemal(paras).then((res) => {
					if(res.data.status.errCode == '10002'){
						sessionStorage.removeItem('token');
						this.$message({
							message: res.data.status.message,
							type: 'warning'
				        });
				        setTimeout(() =>{
				        	this.router({path: '/login'})
				        }, 1500);
						return;
					}
					this.total = res.data.data.total
					this.cardList = res.data.data.data
					this.listLoading = false
				});
			},
			isZoom(imgSrc) {
				this.zoom_img = imgSrc
				this.is_zoom_img = !this.is_zoom_img
			},
			// 查看初称详情
			viewDetails1(index) {
				this.detailsVisible = true
				this.details = this.cardList[index].weightdata
			},
			// 查看回称详情
			viewDetails2(index) {
				this.detailsVisible2 = true
				this.details = this.cardList[index].weightdata
			},
			//显示编辑界面
			handleEdit: function (index, row, type) {
				this.editText = row.order_systemnumber
				switch(type) {
					case 'purchase_weight':
						this.editType = 'purchase_weight';
						this.editForm = {
							purchase_weight: row.flow_extemal.purchase_weight,
						};
						this.title = '修改采购重量'
						break;
					case 'discharge_weight':
						this.editType = 'discharge_weight';
						this.editForm = {
							discharge_weight: row.flow_extemal.discharge_weight,
						};
						this.title = '修改卸货重量'
						break;
					case 'pick_weight':
						this.editType = 'pick_weight';
						this.editForm = {
							pick_weight: row.flow_extemal.pick_weight,
						};
						this.title = '修改提货重量'
						break;
					case 'out_weight':
						this.editType = 'out_weight';
						this.editForm = {
							out_weight: row.flow_extemal.out_weight,
						};
						this.title = '修改出门重量'
						break;
					case 'is_return':
						this.editType = 'is_return';
						this.editForm = {
							is_return: row.flow_extemal.is_return,
						};
						this.title = '是否退货'
						break;
					case 'is_go':
						this.editType = 'is_go';
						this.editForm = {
							is_go: row.flow_extemal.is_go,
						};
						this.title = '是否可以出门'
						break;
					case 'remarks':
						this.editType = 'remarks';
						this.editForm = {
							remarks: row.flow_extemal.remarks,
						};
						this.title = '修改异常备案'
						break;
				}
				this.editFormVisible = true;
			},
			//编辑
			editSubmit: function () {
				this.$refs.editForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.editLoading = true;
							let para = Object.assign({}, this.editForm);
							flowExtemalEdit(this.editText, this.editType, para).then((res) => {
								if(res.data.status.errCode != '0'){
									this.$message({
										message: res.data.status.message,
										type: 'error'
									});
								}else{
									this.$message({
										message: res.data.status.message,
										type: 'success'
									});
								}
								this.editLoading = false;
								this.$refs['editForm'].resetFields();
								this.editFormVisible = false;
								this.flowExtemal(this.screenForm);
							}).catch((err) => {
								console.dir(err)
							});
						});
					}
				});
			},
            //显示查询界面
            screenEdit: function () {
                this.screenFormVisible = true;
                this.screenForm = this.screenForm
            },
            //查询
            screenSubmit: function () {
                this.$refs.screenForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.screenLoading = true;
                            let para = Object.assign({}, this.screenForm);
                            this.screenFormVisible = false;
							this.flowExtemal(para);
                            this.screenLoading = false;
                        });
                    }
                });
            },
            // 打印界面
            showPrint: function (index, row) {
                if(!row.weightdata || !row.flow_extemal){
                	this.$message({
						message: '该条数据有问题，不能打印',
						type: 'error'
	                });
                	this.printFormVisible = false;
                	return;
                }
                this.printFormVisible = true;
                this.printForm = {
                	vehicle_number: `车牌号: ${row.weightdata.vehicle_number}`,
					system_datetime: `制卡时间: ${row.system_datetime}`,
					ic_id: `IC卡卡号: ${row.ic_id}`,
					ic_print_code: `印刷编号: ${row.ic_print_code}`,
					process_number_desc: `流程类型: ${row.weightdata.process_number_desc}`,
					sfz_number: `司机身份证号码: ${row.sfz_number}`,
					purchase_weight: `采购重量: ${(row.weightdata.process_number == 'SALEBACK' || row.weightdata.process_number == 'PURCHASE') ? row.flow_extemal.purchase_weight : '0'}`,
					discharge_weight: `卸货重量: ${(row.weightdata.process_number == 'SALEBACK' || row.weightdata.process_number == 'PURCHASE') ? row.flow_extemal.discharge_weight : '0'}`,
					relative_weight: `误差重量: ${(row.weightdata.process_number == 'SALEBACK' || row.weightdata.process_number == 'PURCHASE') ? row.flow_extemal.relative_weight : '0'}`,
					pick_weight: `提货重量: ${(row.weightdata.process_number == 'SALE') ? row.flow_extemal.pick_weight : 0}`,
					out_weight: `出门重量: ${(row.weightdata.process_number == 'SALE') ? row.flow_extemal.out_weight : 0}`,
					net_weight: `地磅净重（卸）: ${(row.weightdata.process_number == 'SALEBACK' || row.weightdata.process_number == 'PURCHASE') ? row.flow_extemal.net_weight : '0'}`,
					net_weight2: `地磅净重（装）: ${(row.weightdata.process_number == 'SALE') ? row.weightdata.net_weight : 0}`,
					is_guobang: `是否过磅: ${row.weightdata.is_finished_desc}`,
					xie: `误差重量（卸）: ${(row.weightdata.process_number == 'SALEBACK' || row.weightdata.process_number == 'PURCHASE') ? row.weightdata.weight_error : '0'}`,
					zhuang: `误差重量（装）: ${(row.weightdata.process_number == 'SALE') ? row.weightdata.weight_error : 0}`,
					weight_error_ratio: `误差比值: ${row.weightdata.weight_error_ratio}`,
					is_finished: `是否成功: ${row.weightdata.is_finished_desc}`,
					is_success: `是否完成: ${row.weightdata.is_success_desc}`,
					second_readic_datetime: `完成时间: ${row.weightdata.second_readic_datetime}`,
					is_return: `是否退货: ${row.flow_extemal.is_return_desc}`,
					is_go: `是否可以出门: ${row.flow_extemal.is_go_desc}`,
					remarks: `异常备案: ${row.flow_extemal.remarks}`,
                }
            },
            printSubmit: function () {
                this.$refs.printForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
				            var str = this.checkList.join(',');
				            sessionStorage.setItem('printing', str);
                            this.printLoading = true;
                            let para = Object.assign({}, this.printForm);
                            this.printFormVisible = false;
                            this.printLoading = false;
                			let routeData = this.$router.resolve({path: '/print'});
                			window.open(routeData.href, '_blank');
                        });
                    }
                });
            },
            printBtn(path) {
				sessionStorage.setItem('printing', path);
    			let routeData = this.$router.resolve({path: '/print', query:{img : 'img'}});
    			window.open(routeData.href, '_blank');
            },
			is_return() {
				isReturn().then((res) => {
					this.is_return_arr = [];
					for(var i in res.data.data){
						var arr = {
							label: res.data.data[i].value,
							value: res.data.data[i].key,
						}
						this.is_return_arr.push(arr)
					}
				}).catch((err) => {
					console.dir(err)
				})
			},
			is_go() {
				isGo().then((res) => {
					this.is_go_arr = [];
					for(var i in res.data.data){
						var arr = {
							label: res.data.data[i].value,
							value: res.data.data[i].key,
						}
						this.is_go_arr.push(arr)
					}
				}).catch((err) => {
					console.dir(err)
				})
			},
			exportT() {
				let para = this.screenForm;
				let paras = '';
                if(para){
                    if(para.currentdate.length>0){
						let begin = new Date(para.currentdate[0]);
						let end = new Date(para.currentdate[1]);
						paras += `&start_time=${begin.getFullYear() + '-' + (begin.getMonth()+1) + '-' + begin.getDate()}`;
						paras += `&end_time=${end.getFullYear() + '-' + (end.getMonth()+1) + '-' + end.getDate()}`;
                    }
                    if(para.is_finished){
                      paras += `&is_finished=${para.is_finished}`
                    }
                    if(para.is_success){
                      paras += `&is_success=${para.is_success}`
                    }
                    if(para.process_number){
                      paras += `&process_number=${para.process_number}`
                    }
                }
				location.href=`${BASEURL}/flow/export?token=${sessionStorage.token}${paras}&pageSize=${sessionStorage.getItem('pagesize')}`;
			},
			shiBang() {
				isShibang().then((res) => {
					console.log(res)
					if(res.data.status.errCode == '0'){
						location.reload()
					}
				}).catch((err) => {
					console.dir(err)
				})
			},
			systemconfig() {
				systemConfig().then((res) => {
					for(var i in res.data.data){
						if(res.data.data[i].identity == 'trial_weight'){
							this.is_shibang = res.data.data[i].deviation
						}
					}
				}).catch((err) => {
					console.log(err)
				})
			}
		},
		mounted() {
			this.flowExtemal();
			this.is_return()
			this.is_go()
			this.systemconfig();
		}
	}

</script>
